﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/FullSite.Master"Inherits="System.Web.Mvc.ViewPage<ToppingControl.Models.TopCordActModel.TopCordAct_DS>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    PRINT_BEfore
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


   <div class="float-left">
   <h2>PRINT_BEFORE</h2>
   </div>
   <div class="float-right">
      <div class="float-left">
         <h3>
            Topping NO.
            <%: Html.DisplayFor(model => model._Topno) %>
         </h3>
      </div>
      <div class="float-left" style="margin-left: 25px;">
         <h3>
            Shift : 1</h3>
      </div>
      <div class="float-left" style="margin-left: 25px;">
         <h3>
            Name :
            <% if (Request.IsAuthenticated)
               { %>
            <%:  User.Identity.Name %></h3>
      </div>
      <% } %>
   </div>


   <br />
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="FeaturedContent" runat="server">
   <style type="text/css">
 #data div
      {
         float: left;
         padding: 0px;
      }
      #data td, #prt td
      {
         font-size: 22px;
         height: 35px;
         text-align: left;
         padding-left: 10px;
      }
      input[type="text"]
      {
         height: 30px;
         width: 20%;
         font-size: 24px; 
         border: 2px solid #999;
      }
      input[type="button"]:hover
      {
         cursor:pointer;
         background-color:#D3FFFF;
         border:2px solid #999;
         font-weight:bold; font-size: 22px;
      }
      input[type="button"]
      {
         cursor:pointer;
         background-color:#FFFFD2;         
         font-weight:bold; font-size: 22px;
         width:185px;
         height:50px;
         color:#333333;
      }
      .hide
      {
      display: none;
      }
</style>
</asp:Content>



<asp:Content ID="Content5" ContentPlaceHolderID="MainContent2" runat="server">
   <table id="prt" width="60%" class="fontTB shadow">
         <tr class="head" >
          <td colspan="2" class="cell" style="padding: 10px 0px; border-top:1px solid #000000">
                Print Topped Cord Before</td>
         </tr>
         <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
                Product Date :
            </td>
            <td class="cell" id="prddt">
                <%= Model._Prddate %> </td>
         </tr>
         <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
               Topped Cord :
            </td>
            <td class="cell" id="topcrd">
              <%= Model._Topcrdcd %>
            </td>
         </tr>
         <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px; width: 35%; ">
               MATERIAL :
            </td>
            <td class="cell" id="cus">
             <%= Model._Manufc %>
            
            </td>
         </tr>
         <tr class="rowb">
            <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
               Tire Cord Lot :
            </td>
            <td class="cell" id="lot">
               <%= Model._Tcrdlot %>
            </td>
         </tr>
         <tr class="rowa">
            <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
              From : </td>
            <td class="cell" id="rFr">
               <input type="text" id="txtFr" value="<%= Model._Rollno %>" maxlength="3" /></td>
         </tr>
          <tr class="rowa">
            <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
              To : </td>
            <td class="cell" id="rTo">
               <input type="text" id="txtRto" value="<%= Model._Rollno %>"  maxlength="3"/></td>
         </tr>        
      </table>

   
   <table width="60%">
   <tr >
   <td style="width:35%"><input id="back" type="button" value="CLOSE"  /></td>   
   <td><input id="prtBef" type="button" value="PRINT"  /> &nbsp;
   <input id="printNext" type="button" value="NEXT"  />
   </td>
   
 
   </tr>
   </table>
       <%--KEY PAD--%>
  <div id="numericInput" >   
   <table id="keypad" class="hide">
         <tr style="border:0"><td colspan="3" style="text-decoration:none; text-align:right;" class="btn">
         <img src="<%: Url.Content("~/Images/power.png")%> "  alt='' width="100px" height="75px" />
         </td></tr>
         <tr class="rowa" >
            <td class="key">
               1
            </td>
            <td class="key">
               2
            </td>
            <td class="key">
               3
            </td>
         </tr>
         <tr class="rowa" >
            <td class="key">
               4
            </td>
            <td class="key">
               5
            </td>
            <td class="key">
               6
            </td>
         </tr>
         <tr class="rowa" >
            <td class="key">
               7
            </td>
            <td class="key">
               8
            </td>
            <td class="key">
               9
            </td>
         </tr>
         <tr class="rowa" >
            <td class="btn">
               DEL
            </td>
            <td class="key">
               0
            </td>
            <td class="key">
               .
            </td>
         </tr>
      </table>
</div>
</asp:Content>

<asp:Content ID="Content6" ContentPlaceHolderID="ScriptsSection" runat="server">
   <% if (false)
      { %>
   <script src="../../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
   <% }; %>
   <script type="text/javascript">
       $(function () {
           $("#prtBef").click(function () {

               if ($.trim($("#txtFr").val()) == "") {
                   alert("ระบุ Rollno");
                   $("#txtFr").focus();
                   return;
               }
               if ($.trim($("#txtRto").val()) != "") {

                   if ($("#txtRto").val() < $("#txtFr").val()) {
                       alert("ระบุค่าไม่ถูกต้อง");
                       $("#txtRto").focus();
                       return;
                   }
               }

               var url = '<%= Url.Action("INDEX","PDF_PRINT") %>';
               var para = '?topcode=' + $("#topcrd").text() + '&cust=' + $("#cus").text()
                              + '&tirelot=' + $("#lot").text()
                              + '&rFrm=' + $("#txtFr").val() + '&rTo=' + $("#txtRto").val()
                              + '&prddt=' + $("#prddt").val();
               window.open(url + para, "printbefore", "fullscreen=no");
           });
           $("#back").click(function () {
               btnBack();
           });
           var dataNext;
           $.post('<%=Url.Action("Get_Next") %>', function (data) {
               if (data.success == 1) {
                   dataNext = data.list;
               }else{
                    $("#printNext").addClass("hide");
               }
           });
           $("#printNext").click(function () {
               if ($(this).val() == "NEXT")
               {
                   $(this).val("BACK");
                   $("#prddt").text(dataNext._Prddate);
                   $("#topcrd").text(dataNext._Topcrdcd);
                   $("#cus").text(dataNext._Manufc);
                   $("#lot").text(dataNext._Tcrdlot);
               }
               else { 
                   $(this).val("NEXT");
                   $("#prddt").text('<%: Model._Prddate %>');
                   $("#topcrd").text('<%: Model._Topcrdcd %>');
                   $("#cus").text('<%: Model._Manufc %>');
                   $("#lot").text('<%: Model._Tcrdlot %>');
               }

           });


           function btnBack(msg) {
               var url = '<%= Url.Action("GET_CARD") %>';
               window.location = url;
           }

           var clickNum = null;
           $('.key').click(function (event) {

               var numBox = clickNum;
               o = numBox.data('mask');

               var max = o.maxLength;

               if (numBox.val().length == max) {
                   return;
               }

               var v = $.trim(this.innerHTML);
               var valueArray = ($.trim(numBox.val())).split('')
               var idx = $.inArray(".", valueArray);

               if ((v == ".") && (idx > -1)) {
                   return;
               }

               if ($.trim(this.innerHTML) == ".") {
                   if ($.inArray(".", o.maskArray) < 0) {
                       return;
                   }
                   numBox.val(numBox.val() + '.');
                   return;
               }

               var i = valueArray.length;


               if (idx >= 0) {
                   var pt = o.maskArray.length - ($.inArray(".", o.maskArray));
                   var x = valueArray.length + 1 - idx;
                   if (x > pt) {
                       return;
                   }
                   i = $.inArray(".", o.maskArray) + 1;


               } else if ((i > 0) && (o.maskArray[i] == '.')) {
                   numBox.val(numBox.val() + '.');
               }

               if (o.maskNonFixedCharsArray[i] == 'undefine') {
                   return;
               }
               if (v <= o.maskNonFixedCharsArray[i]) {
                   numBox.val(numBox.val() + v);
               }

               event.stopPropagation();
           });

           $('.btn').click(function (event) {
               var numBox = clickNum
               if ($.trim(this.innerHTML) == 'DEL') {
                   if (numBox.val().length > 0) {
                       clickNum.val(numBox.val().substring(0, numBox.val().length - 1));
                   }
                   else {
                       numBox.val('');
                   }
               }
               else {
                   $("#keypad").slideToggle();
                   clickNum = null;
               }
               event.stopPropagation();
           });

           $('#txtFr,#txtRto')
               .setMask("999").attr("maxlength", 3);
           $("#txtFr,#txtRto").click(function (event) {
               var parentOffset = $(this).offset();
               var o = {
                   left: event.pageX - parentOffset.left + 100,
                   top: event.pageY - parentOffset.top + 150
               };

               if ((clickNum == null) || ($(this).attr("id") == clickNum.attr("id"))) $("#keypad").slideToggle().offset(o);
               clickNum = $(this);
               event.stopPropagation();
           });

       });
   </script>
</asp:Content>
